#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string ans;
int n;
char get(int x)
{
	if (x <= 9)return x + '0';
	else return x - 10 + 'A';
}
bool fun(string s)
{
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != s[s.size() - 1 - i])return 0;
	}
	return 1;
}
bool check(int x, int n)
{
	string s;
	int t = x;
	while (t) {
		//s += (t % n) + '0';
		s += get(t % n);
		t /= n;
	}
	//cout<<"s==="<<s<<endl;
	reverse(s.begin(), s.end());
	if (fun(s)) {
		ans = s;
		//cout<<"s==="<<s<<endl;
		return 1;
	}
	return 0;
}

string fun1(int x, int n)
{
	string res;
	while (x) {
		res += get(x % n);
		x /= n;
	}
	reverse(res.begin(), res.end());
	return res;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= 300; i++) {
		ans = "";
		if (check(i * i, n)) {
			cout << fun1(i, n) << " " << ans << endl;
		}
	}
	return 0;
}